#include "Mustache.h"
#include <iostream>
#include "mustache.hpp"


namespace
{
    std::string GetContent(std::string path)
    {
        std::string res;
        std::ifstream ifs(path, std::ios::in);

        while (!ifs.eof())
        {
            std::string token;
            ifs >> token;
            res += token;
        }
        return res;
    }
}

std::string Mustache::Render(const basic_data<std::string> &data)
{
    return m_temp.render(data);
}

Mustache *Mustache::CreateFromFile(std::string path)
{
    Mustache* res = new Mustache();
    res->m_temp = mustache(GetContent(path));
    return res;
}